﻿using System;
using System.Diagnostics.Contracts;

namespace AnthStat.Infrastructure.Statistics
{
    public static class WHO2006
    {
        #region WHO 2006 Growth Standards Data

        private static readonly double[,] WHO2006HtAge = { 
                                                { 1,0,1,49.8842,0.03795 },
{ 1,1,1,54.7244,0.03557 },
{ 1,2,1,58.4249,0.03424 },
{ 1,3,1,61.4292,0.03328 },
{ 1,4,1,63.886,0.03257 },
{ 1,5,1,65.9026,0.03204 },
{ 1,6,1,67.6236,0.03165 },
{ 1,7,1,69.1645,0.03139 },
{ 1,8,1,70.5994,0.03124 },
{ 1,9,1,71.9687,0.03117 },
{ 1,10,1,73.2812,0.03118 },
{ 1,11,1,74.5388,0.03125 },
{ 1,12,1,75.7488,0.03137 },
{ 1,13,1,76.9186,0.03154 },
{ 1,14,1,78.0497,0.03174 },
{ 1,15,1,79.1458,0.03197 },
{ 1,16,1,80.2113,0.03222 },
{ 1,17,1,81.2487,0.0325 },
{ 1,18,1,82.2587,0.03279 },
{ 1,19,1,83.2418,0.0331 },
{ 1,20,1,84.1996,0.03342 },
{ 1,21,1,85.1348,0.03376 },
{ 1,22,1,86.0477,0.0341 },
{ 1,23,1,86.941,0.03445 },
{ 1,24,1,87.8161,0.03479 },
{ 1,24,1,87.1161,0.03507 },
{ 1,25,1,87.972,0.03542 },
{ 1,26,1,88.8065,0.03576 },
{ 1,27,1,89.6197,0.0361 },
{ 1,28,1,90.412,0.03642 },
{ 1,29,1,91.1828,0.03674 },
{ 1,30,1,91.9327,0.03704 },
{ 1,31,1,92.6631,0.03733 },
{ 1,32,1,93.3753,0.03761 },
{ 1,33,1,94.0711,0.03787 },
{ 1,34,1,94.7532,0.03812 },
{ 1,35,1,95.4236,0.03836 },
{ 1,36,1,96.0835,0.03858 },
{ 1,37,1,96.7337,0.03879 },
{ 1,38,1,97.3749,0.039 },
{ 1,39,1,98.0073,0.03919 },
{ 1,40,1,98.631,0.03937 },
{ 1,41,1,99.2459,0.03954 },
{ 1,42,1,99.8515,0.03971 },
{ 1,43,1,100.4485,0.03986 },
{ 1,44,1,101.0374,0.04002 },
{ 1,45,1,101.6186,0.04016 },
{ 1,46,1,102.1933,0.04031 },
{ 1,47,1,102.7625,0.04045 },
{ 1,48,1,103.3273,0.04059 },
{ 1,49,1,103.8886,0.04073 },
{ 1,50,1,104.4473,0.04086 },
{ 1,51,1,105.0041,0.041 },
{ 1,52,1,105.5596,0.04113 },
{ 1,53,1,106.1138,0.04126 },
{ 1,54,1,106.6668,0.04139 },
{ 1,55,1,107.2188,0.04152 },
{ 1,56,1,107.7697,0.04165 },
{ 1,57,1,108.3198,0.04177 },
{ 1,58,1,108.8689,0.0419 },
{ 1,59,1,109.417,0.04202 },
{ 1,60,1,109.9638,0.04214 },
{ 2,0,1,49.1477,0.0379 },
{ 2,1,1,53.6872,0.0364 },
{ 2,2,1,57.0673,0.03568 },
{ 2,3,1,59.8029,0.0352 },
{ 2,4,1,62.0899,0.03486 },
{ 2,5,1,64.0301,0.03463 },
{ 2,6,1,65.7311,0.03448 },
{ 2,7,1,67.2873,0.03441 },
{ 2,8,1,68.7498,0.0344 },
{ 2,9,1,70.1435,0.03444 },
{ 2,10,1,71.4818,0.03452 },
{ 2,11,1,72.771,0.03464 },
{ 2,12,1,74.015,0.03479 },
{ 2,13,1,75.2176,0.03496 },
{ 2,14,1,76.3817,0.03514 },
{ 2,15,1,77.5099,0.03534 },
{ 2,16,1,78.6055,0.03555 },
{ 2,17,1,79.671,0.03576 },
{ 2,18,1,80.7079,0.03598 },
{ 2,19,1,81.7182,0.0362 },
{ 2,20,1,82.7036,0.03643 },
{ 2,21,1,83.6654,0.03666 },
{ 2,22,1,84.604,0.03688 },
{ 2,23,1,85.5202,0.03711 },
{ 2,24,1,86.4153,0.03734 },
{ 2,24,1,85.7153,0.03764 },
{ 2,25,1,86.5904,0.03786 },
{ 2,26,1,87.4462,0.03808 },
{ 2,27,1,88.283,0.0383 },
{ 2,28,1,89.1004,0.03851 },
{ 2,29,1,89.8991,0.03872 },
{ 2,30,1,90.6797,0.03893 },
{ 2,31,1,91.443,0.03913 },
{ 2,32,1,92.1906,0.03933 },
{ 2,33,1,92.9239,0.03952 },
{ 2,34,1,93.6444,0.03971 },
{ 2,35,1,94.3533,0.03989 },
{ 2,36,1,95.0515,0.04006 },
{ 2,37,1,95.7399,0.04024 },
{ 2,38,1,96.4187,0.04041 },
{ 2,39,1,97.0885,0.04057 },
{ 2,40,1,97.7493,0.04073 },
{ 2,41,1,98.4015,0.04089 },
{ 2,42,1,99.0448,0.04105 },
{ 2,43,1,99.6795,0.0412 },
{ 2,44,1,100.3058,0.04135 },
{ 2,45,1,100.9238,0.0415 },
{ 2,46,1,101.5337,0.04164 },
{ 2,47,1,102.136,0.04179 },
{ 2,48,1,102.7312,0.04193 },
{ 2,49,1,103.3197,0.04206 },
{ 2,50,1,103.9021,0.0422 },
{ 2,51,1,104.4786,0.04233 },
{ 2,52,1,105.0494,0.04246 },
{ 2,53,1,105.6148,0.04259 },
{ 2,54,1,106.1748,0.04272 },
{ 2,55,1,106.7295,0.04285 },
{ 2,56,1,107.2788,0.04298 },
{ 2,57,1,107.8227,0.0431 },
{ 2,58,1,108.3613,0.04322 },
{ 2,59,1,108.8948,0.04334 },
{ 2,60,1,109.4233,0.04347 }
                                                };
        private static readonly double[,] WHO2006LgthAge = { 
                                                  { 1, 1 } 
                                                  };
        private static readonly double[,] WHO2006WtAge = { 
                                                { 1,0,0.3487,3.3464,0.14602 },
{ 1,1,0.2297,4.4709,0.13395 },
{ 1,2,0.197,5.5675,0.12385 },
{ 1,3,0.1738,6.3762,0.11727 },
{ 1,4,0.1553,7.0023,0.11316 },
{ 1,5,0.1395,7.5105,0.1108 },
{ 1,6,0.1257,7.934,0.10958 },
{ 1,7,0.1134,8.297,0.10902 },
{ 1,8,0.1021,8.6151,0.10882 },
{ 1,9,0.0917,8.9014,0.10881 },
{ 1,10,0.082,9.1649,0.10891 },
{ 1,11,0.073,9.4122,0.10906 },
{ 1,12,0.0644,9.6479,0.10925 },
{ 1,13,0.0563,9.8749,0.10949 },
{ 1,14,0.0487,10.0953,0.10976 },
{ 1,15,0.0413,10.3108,0.11007 },
{ 1,16,0.0343,10.5228,0.11041 },
{ 1,17,0.0275,10.7319,0.11079 },
{ 1,18,0.0211,10.9385,0.11119 },
{ 1,19,0.0148,11.143,0.11164 },
{ 1,20,0.0087,11.3462,0.11211 },
{ 1,21,0.0029,11.5486,0.11261 },
{ 1,22,-0.0028,11.7504,0.11314 },
{ 1,23,-0.0083,11.9514,0.11369 },
{ 1,24,-0.0137,12.1515,0.11426 },
{ 1,25,-0.0189,12.3502,0.11485 },
{ 1,26,-0.024,12.5466,0.11544 },
{ 1,27,-0.0289,12.7401,0.11604 },
{ 1,28,-0.0337,12.9303,0.11664 },
{ 1,29,-0.0385,13.1169,0.11723 },
{ 1,30,-0.0431,13.3,0.11781 },
{ 1,31,-0.0476,13.4798,0.11839 },
{ 1,32,-0.052,13.6567,0.11896 },
{ 1,33,-0.0564,13.8309,0.11953 },
{ 1,34,-0.0606,14.0031,0.12008 },
{ 1,35,-0.0648,14.1736,0.12062 },
{ 1,36,-0.0689,14.3429,0.12116 },
{ 1,37,-0.0729,14.5113,0.12168 },
{ 1,38,-0.0769,14.6791,0.1222 },
{ 1,39,-0.0808,14.8466,0.12271 },
{ 1,40,-0.0846,15.014,0.12322 },
{ 1,41,-0.0883,15.1813,0.12373 },
{ 1,42,-0.092,15.3486,0.12425 },
{ 1,43,-0.0957,15.5158,0.12478 },
{ 1,44,-0.0993,15.6828,0.12531 },
{ 1,45,-0.1028,15.8497,0.12586 },
{ 1,46,-0.1063,16.0163,0.12643 },
{ 1,47,-0.1097,16.1827,0.127 },
{ 1,48,-0.1131,16.3489,0.12759 },
{ 1,49,-0.1165,16.515,0.12819 },
{ 1,50,-0.1198,16.6811,0.1288 },
{ 1,51,-0.123,16.8471,0.12943 },
{ 1,52,-0.1262,17.0132,0.13005 },
{ 1,53,-0.1294,17.1792,0.13069 },
{ 1,54,-0.1325,17.3452,0.13133 },
{ 1,55,-0.1356,17.5111,0.13197 },
{ 1,56,-0.1387,17.6768,0.13261 },
{ 1,57,-0.1417,17.8422,0.13325 },
{ 1,58,-0.1447,18.0073,0.13389 },
{ 1,59,-0.1477,18.1722,0.13453 },
{ 1,60,-0.1506,18.3366,0.13517 },
{ 2,0,0.3809,3.2322,0.14171 },
{ 2,1,0.1714,4.1873,0.13724 },
{ 2,2,0.0962,5.1282,0.13 },
{ 2,3,0.0402,5.8458,0.12619 },
{ 2,4,-0.005,6.4237,0.12402 },
{ 2,5,-0.043,6.8985,0.12274 },
{ 2,6,-0.0756,7.297,0.12204 },
{ 2,7,-0.1039,7.6422,0.12178 },
{ 2,8,-0.1288,7.9487,0.12181 },
{ 2,9,-0.1507,8.2254,0.12199 },
{ 2,10,-0.17,8.48,0.12223 },
{ 2,11,-0.1872,8.7192,0.12247 },
{ 2,12,-0.2024,8.9481,0.12268 },
{ 2,13,-0.2158,9.1699,0.12283 },
{ 2,14,-0.2278,9.387,0.12294 },
{ 2,15,-0.2384,9.6008,0.12299 },
{ 2,16,-0.2478,9.8124,0.12303 },
{ 2,17,-0.2562,10.0226,0.12306 },
{ 2,18,-0.2637,10.2315,0.12309 },
{ 2,19,-0.2703,10.4393,0.12315 },
{ 2,20,-0.2762,10.6464,0.12323 },
{ 2,21,-0.2815,10.8534,0.12335 },
{ 2,22,-0.2862,11.0608,0.1235 },
{ 2,23,-0.2903,11.2688,0.12369 },
{ 2,24,-0.2941,11.4775,0.1239 },
{ 2,25,-0.2975,11.6864,0.12414 },
{ 2,26,-0.3005,11.8947,0.12441 },
{ 2,27,-0.3032,12.1015,0.12472 },
{ 2,28,-0.3057,12.3059,0.12506 },
{ 2,29,-0.308,12.5073,0.12545 },
{ 2,30,-0.3101,12.7055,0.12587 },
{ 2,31,-0.312,12.9006,0.12633 },
{ 2,32,-0.3138,13.093,0.12683 },
{ 2,33,-0.3155,13.2837,0.12737 },
{ 2,34,-0.3171,13.4731,0.12794 },
{ 2,35,-0.3186,13.6618,0.12855 },
{ 2,36,-0.3201,13.8503,0.12919 },
{ 2,37,-0.3216,14.0385,0.12988 },
{ 2,38,-0.323,14.2265,0.13059 },
{ 2,39,-0.3243,14.414,0.13135 },
{ 2,40,-0.3257,14.601,0.13213 },
{ 2,41,-0.327,14.7873,0.13293 },
{ 2,42,-0.3283,14.9727,0.13376 },
{ 2,43,-0.3296,15.1573,0.1346 },
{ 2,44,-0.3309,15.341,0.13545 },
{ 2,45,-0.3322,15.524,0.1363 },
{ 2,46,-0.3335,15.7064,0.13716 },
{ 2,47,-0.3348,15.8882,0.138 },
{ 2,48,-0.3361,16.0697,0.13884 },
{ 2,49,-0.3374,16.2511,0.13968 },
{ 2,50,-0.3387,16.4322,0.14051 },
{ 2,51,-0.34,16.6133,0.14132 },
{ 2,52,-0.3414,16.7942,0.14213 },
{ 2,53,-0.3427,16.9748,0.14293 },
{ 2,54,-0.344,17.1551,0.14371 },
{ 2,55,-0.3453,17.3347,0.14448 },
{ 2,56,-0.3466,17.5136,0.14525 },
{ 2,57,-0.3479,17.6916,0.146 },
{ 2,58,-0.3492,17.8686,0.14675 },
{ 2,59,-0.3505,18.0445,0.14748 },
{ 2,60,-0.3518,18.2193,0.14821 }
                                                };
        private static readonly double[,] WHO2006WtHt = { 
                                               { 1,65,-0.3521,7.4327,0.08217 },
{ 1,65.5,-0.3521,7.5504,0.08214 },
{ 1,66,-0.3521,7.6673,0.08212 },
{ 1,66.5,-0.3521,7.7834,0.08212 },
{ 1,67,-0.3521,7.8986,0.08213 },
{ 1,67.5,-0.3521,8.0132,0.08214 },
{ 1,68,-0.3521,8.1272,0.08217 },
{ 1,68.5,-0.3521,8.241,0.08221 },
{ 1,69,-0.3521,8.3547,0.08226 },
{ 1,69.5,-0.3521,8.468,0.08231 },
{ 1,70,-0.3521,8.5808,0.08237 },
{ 1,70.5,-0.3521,8.6927,0.08243 },
{ 1,71,-0.3521,8.8036,0.0825 },
{ 1,71.5,-0.3521,8.9135,0.08257 },
{ 1,72,-0.3521,9.0221,0.08264 },
{ 1,72.5,-0.3521,9.1292,0.08272 },
{ 1,73,-0.3521,9.2347,0.08278 },
{ 1,73.5,-0.3521,9.339,0.08285 },
{ 1,74,-0.3521,9.442,0.08292 },
{ 1,74.5,-0.3521,9.5438,0.08298 },
{ 1,75,-0.3521,9.644,0.08303 },
{ 1,75.5,-0.3521,9.7425,0.08308 },
{ 1,76,-0.3521,9.8392,0.08312 },
{ 1,76.5,-0.3521,9.9341,0.08315 },
{ 1,77,-0.3521,10.0274,0.08317 },
{ 1,77.5,-0.3521,10.1194,0.08318 },
{ 1,78,-0.3521,10.2105,0.08317 },
{ 1,78.5,-0.3521,10.3012,0.08315 },
{ 1,79,-0.3521,10.3923,0.08311 },
{ 1,79.5,-0.3521,10.4845,0.08305 },
{ 1,80,-0.3521,10.5781,0.08298 },
{ 1,80.5,-0.3521,10.6737,0.0829 },
{ 1,81,-0.3521,10.7718,0.08279 },
{ 1,81.5,-0.3521,10.8728,0.08268 },
{ 1,82,-0.3521,10.9772,0.08255 },
{ 1,82.5,-0.3521,11.0851,0.08241 },
{ 1,83,-0.3521,11.1966,0.08225 },
{ 1,83.5,-0.3521,11.3114,0.08209 },
{ 1,84,-0.3521,11.429,0.08191 },
{ 1,84.5,-0.3521,11.549,0.08174 },
{ 1,85,-0.3521,11.6707,0.08156 },
{ 1,85.5,-0.3521,11.7937,0.08138 },
{ 1,86,-0.3521,11.9173,0.08121 },
{ 1,86.5,-0.3521,12.0411,0.08105 },
{ 1,87,-0.3521,12.1645,0.0809 },
{ 1,87.5,-0.3521,12.2871,0.08076 },
{ 1,88,-0.3521,12.4089,0.08064 },
{ 1,88.5,-0.3521,12.5298,0.08054 },
{ 1,89,-0.3521,12.6495,0.08045 },
{ 1,89.5,-0.3521,12.7683,0.08038 },
{ 1,90,-0.3521,12.8864,0.08032 },
{ 1,90.5,-0.3521,13.0038,0.08028 },
{ 1,91,-0.3521,13.1209,0.08025 },
{ 1,91.5,-0.3521,13.2376,0.08024 },
{ 1,92,-0.3521,13.3541,0.08025 },
{ 1,92.5,-0.3521,13.4705,0.08027 },
{ 1,93,-0.3521,13.587,0.08031 },
{ 1,93.5,-0.3521,13.7041,0.08036 },
{ 1,94,-0.3521,13.8217,0.08043 },
{ 1,94.5,-0.3521,13.9403,0.08051 },
{ 1,95,-0.3521,14.06,0.0806 },
{ 1,95.5,-0.3521,14.1811,0.08071 },
{ 1,96,-0.3521,14.3037,0.08083 },
{ 1,96.5,-0.3521,14.4282,0.08097 },
{ 1,97,-0.3521,14.5547,0.08112 },
{ 1,97.5,-0.3521,14.6832,0.08129 },
{ 1,98,-0.3521,14.814,0.08146 },
{ 1,98.5,-0.3521,14.9468,0.08165 },
{ 1,99,-0.3521,15.0818,0.08185 },
{ 1,99.5,-0.3521,15.2187,0.08206 },
{ 1,100,-0.3521,15.3576,0.08229 },
{ 1,100.5,-0.3521,15.4985,0.08252 },
{ 1,101,-0.3521,15.6412,0.08277 },
{ 1,101.5,-0.3521,15.7857,0.08302 },
{ 1,102,-0.3521,15.932,0.08328 },
{ 1,102.5,-0.3521,16.0801,0.08354 },
{ 1,103,-0.3521,16.2298,0.08381 },
{ 1,103.5,-0.3521,16.3812,0.08408 },
{ 1,104,-0.3521,16.5342,0.08436 },
{ 1,104.5,-0.3521,16.6889,0.08464 },
{ 1,105,-0.3521,16.8454,0.08493 },
{ 1,105.5,-0.3521,17.0036,0.08521 },
{ 1,106,-0.3521,17.1637,0.08551 },
{ 1,106.5,-0.3521,17.3256,0.0858 },
{ 1,107,-0.3521,17.4894,0.08611 },
{ 1,107.5,-0.3521,17.655,0.08641 },
{ 1,108,-0.3521,17.8226,0.08673 },
{ 1,108.5,-0.3521,17.9924,0.08704 },
{ 1,109,-0.3521,18.1645,0.08736 },
{ 1,109.5,-0.3521,18.339,0.08768 },
{ 1,110,-0.3521,18.5158,0.088 },
{ 1,110.5,-0.3521,18.6948,0.08832 },
{ 1,111,-0.3521,18.8759,0.08864 },
{ 1,111.5,-0.3521,19.059,0.08896 },
{ 1,112,-0.3521,19.2439,0.08928 },
{ 1,112.5,-0.3521,19.4304,0.0896 },
{ 1,113,-0.3521,19.6185,0.08991 },
{ 1,113.5,-0.3521,19.8081,0.09022 },
{ 1,114,-0.3521,19.999,0.09054 },
{ 1,114.5,-0.3521,20.1912,0.09085 },
{ 1,115,-0.3521,20.3846,0.09116 },
{ 1,115.5,-0.3521,20.5789,0.09147 },
{ 1,116,-0.3521,20.7741,0.09177 },
{ 1,116.5,-0.3521,20.97,0.09208 },
{ 1,117,-0.3521,21.1666,0.09239 },
{ 1,117.5,-0.3521,21.3636,0.0927 },
{ 1,118,-0.3521,21.5611,0.093 },
{ 1,118.5,-0.3521,21.7588,0.09331 },
{ 1,119,-0.3521,21.9568,0.09362 },
{ 1,119.5,-0.3521,22.1549,0.09393 },
{ 1,120,-0.3521,22.353,0.09424 },
{ 2,65,-0.3833,7.2402,0.09113 },
{ 2,65.5,-0.3833,7.3523,0.09109 },
{ 2,66,-0.3833,7.463,0.09104 },
{ 2,66.5,-0.3833,7.5724,0.09099 },
{ 2,67,-0.3833,7.6806,0.09094 },
{ 2,67.5,-0.3833,7.7874,0.09088 },
{ 2,68,-0.3833,7.893,0.09083 },
{ 2,68.5,-0.3833,7.9976,0.09077 },
{ 2,69,-0.3833,8.1012,0.09071 },
{ 2,69.5,-0.3833,8.2039,0.09065 },
{ 2,70,-0.3833,8.3058,0.09059 },
{ 2,70.5,-0.3833,8.4071,0.09053 },
{ 2,71,-0.3833,8.5078,0.09047 },
{ 2,71.5,-0.3833,8.6078,0.09041 },
{ 2,72,-0.3833,8.707,0.09035 },
{ 2,72.5,-0.3833,8.8053,0.09028 },
{ 2,73,-0.3833,8.9025,0.09022 },
{ 2,73.5,-0.3833,8.9983,0.09016 },
{ 2,74,-0.3833,9.0928,0.09009 },
{ 2,74.5,-0.3833,9.1862,0.09003 },
{ 2,75,-0.3833,9.2786,0.08996 },
{ 2,75.5,-0.3833,9.3703,0.08989 },
{ 2,76,-0.3833,9.4617,0.08983 },
{ 2,76.5,-0.3833,9.5533,0.08976 },
{ 2,77,-0.3833,9.6456,0.08969 },
{ 2,77.5,-0.3833,9.739,0.08963 },
{ 2,78,-0.3833,9.8338,0.08956 },
{ 2,78.5,-0.3833,9.9303,0.0895 },
{ 2,79,-0.3833,10.0289,0.08943 },
{ 2,79.5,-0.3833,10.1298,0.08937 },
{ 2,80,-0.3833,10.2332,0.08932 },
{ 2,80.5,-0.3833,10.3393,0.08926 },
{ 2,81,-0.3833,10.4477,0.08921 },
{ 2,81.5,-0.3833,10.5586,0.08916 },
{ 2,82,-0.3833,10.6719,0.08912 },
{ 2,82.5,-0.3833,10.7874,0.08908 },
{ 2,83,-0.3833,10.9051,0.08905 },
{ 2,83.5,-0.3833,11.0248,0.08902 },
{ 2,84,-0.3833,11.1462,0.08899 },
{ 2,84.5,-0.3833,11.2691,0.08897 },
{ 2,85,-0.3833,11.3934,0.08896 },
{ 2,85.5,-0.3833,11.5186,0.08895 },
{ 2,86,-0.3833,11.6444,0.08895 },
{ 2,86.5,-0.3833,11.7705,0.08895 },
{ 2,87,-0.3833,11.8965,0.08896 },
{ 2,87.5,-0.3833,12.0223,0.08897 },
{ 2,88,-0.3833,12.1478,0.08899 },
{ 2,88.5,-0.3833,12.2729,0.08901 },
{ 2,89,-0.3833,12.3976,0.08904 },
{ 2,89.5,-0.3833,12.522,0.08907 },
{ 2,90,-0.3833,12.6461,0.08911 },
{ 2,90.5,-0.3833,12.77,0.08915 },
{ 2,91,-0.3833,12.8939,0.0892 },
{ 2,91.5,-0.3833,13.0177,0.08925 },
{ 2,92,-0.3833,13.1415,0.08931 },
{ 2,92.5,-0.3833,13.2654,0.08937 },
{ 2,93,-0.3833,13.3896,0.08944 },
{ 2,93.5,-0.3833,13.5142,0.08951 },
{ 2,94,-0.3833,13.6393,0.08959 },
{ 2,94.5,-0.3833,13.765,0.08967 },
{ 2,95,-0.3833,13.8914,0.08975 },
{ 2,95.5,-0.3833,14.0186,0.08984 },
{ 2,96,-0.3833,14.1466,0.08994 },
{ 2,96.5,-0.3833,14.2757,0.09004 },
{ 2,97,-0.3833,14.4059,0.09015 },
{ 2,97.5,-0.3833,14.5376,0.09026 },
{ 2,98,-0.3833,14.671,0.09037 },
{ 2,98.5,-0.3833,14.8062,0.09049 },
{ 2,99,-0.3833,14.9434,0.09062 },
{ 2,99.5,-0.3833,15.0828,0.09075 },
{ 2,100,-0.3833,15.2246,0.09088 },
{ 2,100.5,-0.3833,15.3687,0.09102 },
{ 2,101,-0.3833,15.5154,0.09116 },
{ 2,101.5,-0.3833,15.6646,0.09131 },
{ 2,102,-0.3833,15.8164,0.09146 },
{ 2,102.5,-0.3833,15.9707,0.09161 },
{ 2,103,-0.3833,16.1276,0.09177 },
{ 2,103.5,-0.3833,16.287,0.09193 },
{ 2,104,-0.3833,16.4488,0.09209 },
{ 2,104.5,-0.3833,16.6131,0.09226 },
{ 2,105,-0.3833,16.78,0.09243 },
{ 2,105.5,-0.3833,16.9496,0.09261 },
{ 2,106,-0.3833,17.122,0.09278 },
{ 2,106.5,-0.3833,17.2973,0.09296 },
{ 2,107,-0.3833,17.4755,0.09315 },
{ 2,107.5,-0.3833,17.6567,0.09333 },
{ 2,108,-0.3833,17.8407,0.09352 },
{ 2,108.5,-0.3833,18.0277,0.09371 },
{ 2,109,-0.3833,18.2174,0.0939 },
{ 2,109.5,-0.3833,18.4096,0.09409 },
{ 2,110,-0.3833,18.6043,0.09428 },
{ 2,110.5,-0.3833,18.8015,0.09448 },
{ 2,111,-0.3833,19.0009,0.09467 },
{ 2,111.5,-0.3833,19.2024,0.09487 },
{ 2,112,-0.3833,19.406,0.09507 },
{ 2,112.5,-0.3833,19.6116,0.09527 },
{ 2,113,-0.3833,19.819,0.09546 },
{ 2,113.5,-0.3833,20.028,0.09566 },
{ 2,114,-0.3833,20.2385,0.09586 },
{ 2,114.5,-0.3833,20.4502,0.09606 },
{ 2,115,-0.3833,20.6629,0.09626 },
{ 2,115.5,-0.3833,20.8766,0.09646 },
{ 2,116,-0.3833,21.0909,0.09666 },
{ 2,116.5,-0.3833,21.3059,0.09686 },
{ 2,117,-0.3833,21.5213,0.09707 },
{ 2,117.5,-0.3833,21.737,0.09727 },
{ 2,118,-0.3833,21.9529,0.09747 },
{ 2,118.5,-0.3833,22.169,0.09767 },
{ 2,119,-0.3833,22.3851,0.09788 },
{ 2,119.5,-0.3833,22.6012,0.09808 },
{ 2,120,-0.3833,22.8173,0.09828 }
                                               };
        private static readonly double[,] WHO2006WtLgth = { 
                                                 { 1,45,-0.3521,2.441,0.09182 },
{ 1,45.5,-0.3521,2.5244,0.09153 },
{ 1,46,-0.3521,2.6077,0.09124 },
{ 1,46.5,-0.3521,2.6913,0.09094 },
{ 1,47,-0.3521,2.7755,0.09065 },
{ 1,47.5,-0.3521,2.8609,0.09036 },
{ 1,48,-0.3521,2.948,0.09007 },
{ 1,48.5,-0.3521,3.0377,0.08977 },
{ 1,49,-0.3521,3.1308,0.08948 },
{ 1,49.5,-0.3521,3.2276,0.08919 },
{ 1,50,-0.3521,3.3278,0.0889 },
{ 1,50.5,-0.3521,3.4311,0.08861 },
{ 1,51,-0.3521,3.5376,0.08831 },
{ 1,51.5,-0.3521,3.6477,0.08801 },
{ 1,52,-0.3521,3.762,0.08771 },
{ 1,52.5,-0.3521,3.8814,0.08741 },
{ 1,53,-0.3521,4.006,0.08711 },
{ 1,53.5,-0.3521,4.1354,0.08681 },
{ 1,54,-0.3521,4.2693,0.08651 },
{ 1,54.5,-0.3521,4.4066,0.08621 },
{ 1,55,-0.3521,4.5467,0.08592 },
{ 1,55.5,-0.3521,4.6892,0.08563 },
{ 1,56,-0.3521,4.8338,0.08535 },
{ 1,56.5,-0.3521,4.9796,0.08507 },
{ 1,57,-0.3521,5.1259,0.08481 },
{ 1,57.5,-0.3521,5.2721,0.08455 },
{ 1,58,-0.3521,5.418,0.0843 },
{ 1,58.5,-0.3521,5.5632,0.08406 },
{ 1,59,-0.3521,5.7074,0.08383 },
{ 1,59.5,-0.3521,5.8501,0.08362 },
{ 1,60,-0.3521,5.9907,0.08342 },
{ 1,60.5,-0.3521,6.1284,0.08324 },
{ 1,61,-0.3521,6.2632,0.08308 },
{ 1,61.5,-0.3521,6.3954,0.08292 },
{ 1,62,-0.3521,6.5251,0.08279 },
{ 1,62.5,-0.3521,6.6527,0.08266 },
{ 1,63,-0.3521,6.7786,0.08255 },
{ 1,63.5,-0.3521,6.9028,0.08245 },
{ 1,64,-0.3521,7.0255,0.08236 },
{ 1,64.5,-0.3521,7.1467,0.08229 },
{ 1,65,-0.3521,7.2666,0.08223 },
{ 1,65.5,-0.3521,7.3854,0.08218 },
{ 1,66,-0.3521,7.5034,0.08215 },
{ 1,66.5,-0.3521,7.6206,0.08213 },
{ 1,67,-0.3521,7.737,0.08212 },
{ 1,67.5,-0.3521,7.8526,0.08212 },
{ 1,68,-0.3521,7.9674,0.08214 },
{ 1,68.5,-0.3521,8.0816,0.08216 },
{ 1,69,-0.3521,8.1955,0.08219 },
{ 1,69.5,-0.3521,8.3092,0.08224 },
{ 1,70,-0.3521,8.4227,0.08229 },
{ 1,70.5,-0.3521,8.5358,0.08235 },
{ 1,71,-0.3521,8.648,0.08241 },
{ 1,71.5,-0.3521,8.7594,0.08248 },
{ 1,72,-0.3521,8.8697,0.08254 },
{ 1,72.5,-0.3521,8.9788,0.08262 },
{ 1,73,-0.3521,9.0865,0.08269 },
{ 1,73.5,-0.3521,9.1927,0.08276 },
{ 1,74,-0.3521,9.2974,0.08283 },
{ 1,74.5,-0.3521,9.401,0.08289 },
{ 1,75,-0.3521,9.5032,0.08295 },
{ 1,75.5,-0.3521,9.6041,0.08301 },
{ 1,76,-0.3521,9.7033,0.08307 },
{ 1,76.5,-0.3521,9.8007,0.08311 },
{ 1,77,-0.3521,9.8963,0.08314 },
{ 1,77.5,-0.3521,9.9902,0.08317 },
{ 1,78,-0.3521,10.0827,0.08318 },
{ 1,78.5,-0.3521,10.1741,0.08318 },
{ 1,79,-0.3521,10.2649,0.08316 },
{ 1,79.5,-0.3521,10.3558,0.08313 },
{ 1,80,-0.3521,10.4475,0.08308 },
{ 1,80.5,-0.3521,10.5405,0.08301 },
{ 1,81,-0.3521,10.6352,0.08293 },
{ 1,81.5,-0.3521,10.7322,0.08284 },
{ 1,82,-0.3521,10.8321,0.08273 },
{ 1,82.5,-0.3521,10.935,0.0826 },
{ 1,83,-0.3521,11.0415,0.08246 },
{ 1,83.5,-0.3521,11.1516,0.08231 },
{ 1,84,-0.3521,11.2651,0.08215 },
{ 1,84.5,-0.3521,11.3817,0.08198 },
{ 1,85,-0.3521,11.5007,0.08181 },
{ 1,85.5,-0.3521,11.6218,0.08163 },
{ 1,86,-0.3521,11.7444,0.08145 },
{ 1,86.5,-0.3521,11.8678,0.08128 },
{ 1,87,-0.3521,11.9916,0.08111 },
{ 1,87.5,-0.3521,12.1152,0.08096 },
{ 1,88,-0.3521,12.2382,0.08082 },
{ 1,88.5,-0.3521,12.3603,0.08069 },
{ 1,89,-0.3521,12.4815,0.08058 },
{ 1,89.5,-0.3521,12.6017,0.08048 },
{ 1,90,-0.3521,12.7209,0.08041 },
{ 1,90.5,-0.3521,12.8392,0.08034 },
{ 1,91,-0.3521,12.9569,0.0803 },
{ 1,91.5,-0.3521,13.0742,0.08026 },
{ 1,92,-0.3521,13.191,0.08025 },
{ 1,92.5,-0.3521,13.3075,0.08025 },
{ 1,93,-0.3521,13.4239,0.08026 },
{ 1,93.5,-0.3521,13.5404,0.08029 },
{ 1,94,-0.3521,13.6572,0.08034 },
{ 1,94.5,-0.3521,13.7746,0.0804 },
{ 1,95,-0.3521,13.8928,0.08047 },
{ 1,95.5,-0.3521,14.012,0.08056 },
{ 1,96,-0.3521,14.1325,0.08067 },
{ 1,96.5,-0.3521,14.2544,0.08078 },
{ 1,97,-0.3521,14.3782,0.08092 },
{ 1,97.5,-0.3521,14.5038,0.08106 },
{ 1,98,-0.3521,14.6316,0.08122 },
{ 1,98.5,-0.3521,14.7614,0.08139 },
{ 1,99,-0.3521,14.8934,0.08157 },
{ 1,99.5,-0.3521,15.0275,0.08177 },
{ 1,100,-0.3521,15.1637,0.08198 },
{ 1,100.5,-0.3521,15.3018,0.0822 },
{ 1,101,-0.3521,15.4419,0.08243 },
{ 1,101.5,-0.3521,15.5838,0.08267 },
{ 1,102,-0.3521,15.7276,0.08292 },
{ 1,102.5,-0.3521,15.8732,0.08317 },
{ 1,103,-0.3521,16.0206,0.08343 },
{ 1,103.5,-0.3521,16.1697,0.0837 },
{ 1,104,-0.3521,16.3204,0.08397 },
{ 1,104.5,-0.3521,16.4728,0.08425 },
{ 1,105,-0.3521,16.6268,0.08453 },
{ 1,105.5,-0.3521,16.7826,0.08481 },
{ 1,106,-0.3521,16.9401,0.0851 },
{ 1,106.5,-0.3521,17.0995,0.08539 },
{ 1,107,-0.3521,17.2607,0.08568 },
{ 1,107.5,-0.3521,17.4237,0.08599 },
{ 1,108,-0.3521,17.5885,0.08629 },
{ 1,108.5,-0.3521,17.7553,0.0866 },
{ 1,109,-0.3521,17.9242,0.08691 },
{ 1,109.5,-0.3521,18.0954,0.08723 },
{ 1,110,-0.3521,18.2689,0.08755 },
{ 2,45,-0.3833,2.4607,0.09029 },
{ 2,45.5,-0.3833,2.5457,0.09033 },
{ 2,46,-0.3833,2.6306,0.09037 },
{ 2,46.5,-0.3833,2.7155,0.0904 },
{ 2,47,-0.3833,2.8007,0.09044 },
{ 2,47.5,-0.3833,2.8867,0.09048 },
{ 2,48,-0.3833,2.9741,0.09052 },
{ 2,48.5,-0.3833,3.0636,0.09056 },
{ 2,49,-0.3833,3.156,0.0906 },
{ 2,49.5,-0.3833,3.252,0.09064 },
{ 2,50,-0.3833,3.3518,0.09068 },
{ 2,50.5,-0.3833,3.4557,0.09072 },
{ 2,51,-0.3833,3.5636,0.09076 },
{ 2,51.5,-0.3833,3.6754,0.0908 },
{ 2,52,-0.3833,3.7911,0.09085 },
{ 2,52.5,-0.3833,3.9105,0.09089 },
{ 2,53,-0.3833,4.0332,0.09093 },
{ 2,53.5,-0.3833,4.1591,0.09098 },
{ 2,54,-0.3833,4.2875,0.09102 },
{ 2,54.5,-0.3833,4.4179,0.09106 },
{ 2,55,-0.3833,4.5498,0.0911 },
{ 2,55.5,-0.3833,4.6827,0.09114 },
{ 2,56,-0.3833,4.8162,0.09118 },
{ 2,56.5,-0.3833,4.95,0.09121 },
{ 2,57,-0.3833,5.0837,0.09125 },
{ 2,57.5,-0.3833,5.2173,0.09128 },
{ 2,58,-0.3833,5.3507,0.0913 },
{ 2,58.5,-0.3833,5.4834,0.09132 },
{ 2,59,-0.3833,5.6151,0.09134 },
{ 2,59.5,-0.3833,5.7454,0.09135 },
{ 2,60,-0.3833,5.8742,0.09136 },
{ 2,60.5,-0.3833,6.0014,0.09137 },
{ 2,61,-0.3833,6.127,0.09137 },
{ 2,61.5,-0.3833,6.2511,0.09136 },
{ 2,62,-0.3833,6.3738,0.09135 },
{ 2,62.5,-0.3833,6.4948,0.09133 },
{ 2,63,-0.3833,6.6144,0.09131 },
{ 2,63.5,-0.3833,6.7328,0.09129 },
{ 2,64,-0.3833,6.8501,0.09126 },
{ 2,64.5,-0.3833,6.9662,0.09123 },
{ 2,65,-0.3833,7.0812,0.09119 },
{ 2,65.5,-0.3833,7.195,0.09115 },
{ 2,66,-0.3833,7.3076,0.0911 },
{ 2,66.5,-0.3833,7.4189,0.09106 },
{ 2,67,-0.3833,7.5288,0.09101 },
{ 2,67.5,-0.3833,7.6375,0.09096 },
{ 2,68,-0.3833,7.7448,0.0909 },
{ 2,68.5,-0.3833,7.8509,0.09085 },
{ 2,69,-0.3833,7.9559,0.09079 },
{ 2,69.5,-0.3833,8.0599,0.09074 },
{ 2,70,-0.3833,8.163,0.09068 },
{ 2,70.5,-0.3833,8.2651,0.09062 },
{ 2,71,-0.3833,8.3666,0.09056 },
{ 2,71.5,-0.3833,8.4676,0.0905 },
{ 2,72,-0.3833,8.5679,0.09043 },
{ 2,72.5,-0.3833,8.6674,0.09037 },
{ 2,73,-0.3833,8.7661,0.09031 },
{ 2,73.5,-0.3833,8.8638,0.09025 },
{ 2,74,-0.3833,8.9601,0.09018 },
{ 2,74.5,-0.3833,9.0552,0.09012 },
{ 2,75,-0.3833,9.149,0.09005 },
{ 2,75.5,-0.3833,9.2418,0.08999 },
{ 2,76,-0.3833,9.3337,0.08992 },
{ 2,76.5,-0.3833,9.4252,0.08985 },
{ 2,77,-0.3833,9.5166,0.08979 },
{ 2,77.5,-0.3833,9.6086,0.08972 },
{ 2,78,-0.3833,9.7015,0.08965 },
{ 2,78.5,-0.3833,9.7957,0.08959 },
{ 2,79,-0.3833,9.8915,0.08952 },
{ 2,79.5,-0.3833,9.9892,0.08946 },
{ 2,80,-0.3833,10.0891,0.0894 },
{ 2,80.5,-0.3833,10.1916,0.08934 },
{ 2,81,-0.3833,10.2965,0.08928 },
{ 2,81.5,-0.3833,10.4041,0.08923 },
{ 2,82,-0.3833,10.514,0.08918 },
{ 2,82.5,-0.3833,10.6263,0.08914 },
{ 2,83,-0.3833,10.741,0.0891 },
{ 2,83.5,-0.3833,10.8578,0.08906 },
{ 2,84,-0.3833,10.9767,0.08903 },
{ 2,84.5,-0.3833,11.0974,0.089 },
{ 2,85,-0.3833,11.2198,0.08898 },
{ 2,85.5,-0.3833,11.3435,0.08897 },
{ 2,86,-0.3833,11.4684,0.08895 },
{ 2,86.5,-0.3833,11.594,0.08895 },
{ 2,87,-0.3833,11.7201,0.08895 },
{ 2,87.5,-0.3833,11.8461,0.08895 },
{ 2,88,-0.3833,11.972,0.08896 },
{ 2,88.5,-0.3833,12.0976,0.08898 },
{ 2,89,-0.3833,12.2229,0.089 },
{ 2,89.5,-0.3833,12.3477,0.08903 },
{ 2,90,-0.3833,12.4723,0.08906 },
{ 2,90.5,-0.3833,12.5965,0.08909 },
{ 2,91,-0.3833,12.7205,0.08913 },
{ 2,91.5,-0.3833,12.8443,0.08918 },
{ 2,92,-0.3833,12.9681,0.08923 },
{ 2,92.5,-0.3833,13.092,0.08928 },
{ 2,93,-0.3833,13.2158,0.08934 },
{ 2,93.5,-0.3833,13.3399,0.08941 },
{ 2,94,-0.3833,13.4643,0.08948 },
{ 2,94.5,-0.3833,13.5892,0.08955 },
{ 2,95,-0.3833,13.7146,0.08963 },
{ 2,95.5,-0.3833,13.8408,0.08972 },
{ 2,96,-0.3833,13.9676,0.08981 },
{ 2,96.5,-0.3833,14.0953,0.0899 },
{ 2,97,-0.3833,14.2239,0.09 },
{ 2,97.5,-0.3833,14.3537,0.0901 },
{ 2,98,-0.3833,14.4848,0.09021 },
{ 2,98.5,-0.3833,14.6174,0.09033 },
{ 2,99,-0.3833,14.7519,0.09044 },
{ 2,99.5,-0.3833,14.8882,0.09057 },
{ 2,100,-0.3833,15.0267,0.09069 },
{ 2,100.5,-0.3833,15.1676,0.09083 },
{ 2,101,-0.3833,15.3108,0.09096 },
{ 2,101.5,-0.3833,15.4564,0.0911 },
{ 2,102,-0.3833,15.6046,0.09125 },
{ 2,102.5,-0.3833,15.7553,0.09139 },
{ 2,103,-0.3833,15.9087,0.09155 },
{ 2,103.5,-0.3833,16.0645,0.0917 },
{ 2,104,-0.3833,16.2229,0.09186 },
{ 2,104.5,-0.3833,16.3837,0.09203 },
{ 2,105,-0.3833,16.547,0.09219 },
{ 2,105.5,-0.3833,16.7129,0.09236 },
{ 2,106,-0.3833,16.8814,0.09254 },
{ 2,106.5,-0.3833,17.0527,0.09271 },
{ 2,107,-0.3833,17.2269,0.09289 },
{ 2,107.5,-0.3833,17.4039,0.09307 },
{ 2,108,-0.3833,17.5839,0.09326 },
{ 2,108.5,-0.3833,17.7668,0.09344 },
{ 2,109,-0.3833,17.9526,0.09363 },
{ 2,109.5,-0.3833,18.1412,0.09382 },
{ 2,110,-0.3833,18.3324,0.09401 }
                                                 };
        private static readonly double[,] WHO2006MUAC = { 
                                               { 1,3,0.3928,13.4817,0.07475 },
{ 1,4,0.3475,13.8097,0.07523 },
{ 1,5,0.3092,14.0585,0.07566 },
{ 1,6,0.2755,14.2389,0.07601 },
{ 1,7,0.2453,14.3678,0.07629 },
{ 1,8,0.2179,14.4591,0.0765 },
{ 1,9,0.1925,14.5245,0.07665 },
{ 1,10,0.169,14.5733,0.07676 },
{ 1,11,0.1469,14.6119,0.07683 },
{ 1,12,0.1261,14.6449,0.07689 },
{ 1,13,0.1064,14.6758,0.07694 },
{ 1,14,0.0876,14.7063,0.07699 },
{ 1,15,0.0697,14.738,0.07703 },
{ 1,16,0.0526,14.7723,0.07707 },
{ 1,17,0.0362,14.8095,0.0771 },
{ 1,18,0.0204,14.8496,0.07713 },
{ 1,19,0.0051,14.8926,0.07717 },
{ 1,20,-0.0097,14.9388,0.07721 },
{ 1,21,-0.0239,14.9883,0.07725 },
{ 1,22,-0.0378,15.041,0.07731 },
{ 1,23,-0.0512,15.0964,0.07738 },
{ 1,24,-0.0643,15.1536,0.07746 },
{ 1,25,-0.077,15.2115,0.07755 },
{ 1,26,-0.0894,15.2693,0.07767 },
{ 1,27,-0.1014,15.3259,0.0778 },
{ 1,28,-0.1132,15.3808,0.07794 },
{ 1,29,-0.1248,15.4336,0.0781 },
{ 1,30,-0.136,15.4839,0.07827 },
{ 1,31,-0.147,15.5317,0.07846 },
{ 1,32,-0.1578,15.5771,0.07866 },
{ 1,33,-0.1684,15.6201,0.07887 },
{ 1,34,-0.1788,15.6611,0.07909 },
{ 1,35,-0.189,15.7003,0.07933 },
{ 1,36,-0.1989,15.738,0.07956 },
{ 1,37,-0.2087,15.7745,0.07981 },
{ 1,38,-0.2184,15.8101,0.08006 },
{ 1,39,-0.2278,15.845,0.08032 },
{ 1,40,-0.2372,15.8793,0.08058 },
{ 1,41,-0.2463,15.9132,0.08085 },
{ 1,42,-0.2553,15.9467,0.08112 },
{ 1,43,-0.2642,15.9797,0.08139 },
{ 1,44,-0.273,16.0124,0.08166 },
{ 1,45,-0.2816,16.0447,0.08194 },
{ 1,46,-0.2901,16.0767,0.08222 },
{ 1,47,-0.2985,16.1085,0.0825 },
{ 1,48,-0.3067,16.14,0.08278 },
{ 1,49,-0.3149,16.1714,0.08307 },
{ 1,50,-0.3229,16.2027,0.08335 },
{ 1,51,-0.3309,16.234,0.08364 },
{ 1,52,-0.3387,16.2654,0.08392 },
{ 1,53,-0.3464,16.2968,0.08421 },
{ 1,54,-0.3541,16.3283,0.0845 },
{ 1,55,-0.3616,16.3599,0.08479 },
{ 1,56,-0.3691,16.3916,0.08508 },
{ 1,57,-0.3765,16.4233,0.08537 },
{ 1,58,-0.3838,16.4551,0.08566 },
{ 1,59,-0.391,16.4871,0.08595 },
{ 1,60,-0.3981,16.5191,0.08624 },
{ 2,3,-0.1733,13.0284,0.08263 },
{ 2,4,-0.1733,13.3649,0.08298 },
{ 2,5,-0.1733,13.6061,0.08325 },
{ 2,6,-0.1733,13.7771,0.08343 },
{ 2,7,-0.1733,13.9018,0.08352 },
{ 2,8,-0.1733,13.9952,0.08351 },
{ 2,9,-0.1733,14.0665,0.08342 },
{ 2,10,-0.1733,14.1217,0.08326 },
{ 2,11,-0.1733,14.1667,0.08305 },
{ 2,12,-0.1733,14.2065,0.0828 },
{ 2,13,-0.1733,14.2455,0.08254 },
{ 2,14,-0.1733,14.2859,0.08227 },
{ 2,15,-0.1733,14.3289,0.08202 },
{ 2,16,-0.1733,14.3752,0.08179 },
{ 2,17,-0.1733,14.4254,0.0816 },
{ 2,18,-0.1733,14.4795,0.08143 },
{ 2,19,-0.1733,14.5372,0.08131 },
{ 2,20,-0.1733,14.5987,0.08123 },
{ 2,21,-0.1733,14.6639,0.08118 },
{ 2,22,-0.1733,14.7328,0.08118 },
{ 2,23,-0.1733,14.8049,0.08121 },
{ 2,24,-0.1733,14.8795,0.08127 },
{ 2,25,-0.1733,14.9559,0.08136 },
{ 2,26,-0.1733,15.0327,0.08147 },
{ 2,27,-0.1733,15.1085,0.08161 },
{ 2,28,-0.1733,15.1817,0.08178 },
{ 2,29,-0.1733,15.2514,0.08196 },
{ 2,30,-0.1733,15.3168,0.08217 },
{ 2,31,-0.1733,15.3779,0.0824 },
{ 2,32,-0.1733,15.4351,0.08265 },
{ 2,33,-0.1733,15.4895,0.08292 },
{ 2,34,-0.1733,15.5423,0.0832 },
{ 2,35,-0.1733,15.5941,0.08351 },
{ 2,36,-0.1733,15.6456,0.08383 },
{ 2,37,-0.1733,15.6969,0.08416 },
{ 2,38,-0.1733,15.7483,0.08451 },
{ 2,39,-0.1733,15.7997,0.08487 },
{ 2,40,-0.1733,15.8509,0.08525 },
{ 2,41,-0.1733,15.9016,0.08563 },
{ 2,42,-0.1733,15.9518,0.08602 },
{ 2,43,-0.1733,16.0016,0.08642 },
{ 2,44,-0.1733,16.0509,0.08683 },
{ 2,45,-0.1733,16.1001,0.08723 },
{ 2,46,-0.1733,16.1491,0.08765 },
{ 2,47,-0.1733,16.1983,0.08806 },
{ 2,48,-0.1733,16.2477,0.08848 },
{ 2,49,-0.1733,16.2974,0.0889 },
{ 2,50,-0.1733,16.3475,0.08932 },
{ 2,51,-0.1733,16.3981,0.08974 },
{ 2,52,-0.1733,16.449,0.09016 },
{ 2,53,-0.1733,16.5001,0.09057 },
{ 2,54,-0.1733,16.5514,0.09099 },
{ 2,55,-0.1733,16.6026,0.0914 },
{ 2,56,-0.1733,16.6534,0.09181 },
{ 2,57,-0.1733,16.7039,0.09221 },
{ 2,58,-0.1733,16.7539,0.09262 },
{ 2,59,-0.1733,16.8034,0.09301 },
{ 2,60,-0.1733,16.8526,0.09341 }
                                               };
        private static readonly double[,] WHO2006BMI = { 
{ 1,0,-0.3053,13.4069,0.0956 },
{ 1,1,0.2708,14.9441,0.09027 },
{ 1,2,0.1118,16.3195,0.08677 },
{ 1,3,0.0068,16.8987,0.08495 },
{ 1,4,-0.0727,17.1579,0.08378 },
{ 1,5,-0.137,17.2919,0.08296 },
{ 1,6,-0.1913,17.3422,0.08234 },
{ 1,7,-0.2385,17.3288,0.08183 },
{ 1,8,-0.2802,17.2647,0.0814 },
{ 1,9,-0.3176,17.1662,0.08102 },
{ 1,10,-0.3516,17.0488,0.08068 },
{ 1,11,-0.3828,16.9239,0.08037 },
{ 1,12,-0.4115,16.7981,0.08009 },
{ 1,13,-0.4382,16.6743,0.07982 },
{ 1,14,-0.463,16.5548,0.07958 },
{ 1,15,-0.4863,16.4409,0.07935 },
{ 1,16,-0.5082,16.3335,0.07913 },
{ 1,17,-0.5289,16.2329,0.07892 },
{ 1,18,-0.5484,16.1392,0.07873 },
{ 1,19,-0.5669,16.0528,0.07854 },
{ 1,20,-0.5846,15.9743,0.07836 },
{ 1,21,-0.6014,15.9039,0.07818 },
{ 1,22,-0.6174,15.8412,0.07802 },
{ 1,23,-0.6328,15.7852,0.07786 },
{ 1,24,-0.6473,15.7356,0.07771 },
{ 1,24,-0.6187,16.0189,0.07785 },
{ 1,25,-0.584,15.98,0.07792 },
{ 1,26,-0.5497,15.9414,0.078 },
{ 1,27,-0.5166,15.9036,0.07808 },
{ 1,28,-0.485,15.8667,0.07818 },
{ 1,29,-0.4552,15.8306,0.07829 },
{ 1,30,-0.4274,15.7953,0.07841 },
{ 1,31,-0.4016,15.7606,0.07854 },
{ 1,32,-0.3782,15.7267,0.07867 },
{ 1,33,-0.3572,15.6934,0.07882 },
{ 1,34,-0.3388,15.661,0.07897 },
{ 1,35,-0.3231,15.6294,0.07914 },
{ 1,36,-0.3101,15.5988,0.07931 },
{ 1,37,-0.3,15.5693,0.0795 },
{ 1,38,-0.2927,15.541,0.07969 },
{ 1,39,-0.2884,15.514,0.0799 },
{ 1,40,-0.2869,15.4885,0.08012 },
{ 1,41,-0.2881,15.4645,0.08036 },
{ 1,42,-0.2919,15.442,0.08061 },
{ 1,43,-0.2981,15.421,0.08087 },
{ 1,44,-0.3067,15.4013,0.08115 },
{ 1,45,-0.3174,15.3827,0.08144 },
{ 1,46,-0.3303,15.3652,0.08174 },
{ 1,47,-0.3452,15.3485,0.08205 },
{ 1,48,-0.3622,15.3326,0.08238 },
{ 1,49,-0.3811,15.3174,0.08272 },
{ 1,50,-0.4019,15.3029,0.08307 },
{ 1,51,-0.4245,15.2891,0.08343 },
{ 1,52,-0.4488,15.2759,0.0838 },
{ 1,53,-0.4747,15.2633,0.08418 },
{ 1,54,-0.5019,15.2514,0.08457 },
{ 1,55,-0.5303,15.24,0.08496 },
{ 1,56,-0.5599,15.2291,0.08536 },
{ 1,57,-0.5905,15.2188,0.08577 },
{ 1,58,-0.6223,15.2091,0.08617 },
{ 1,59,-0.6552,15.2,0.08659 },
{ 1,60,-0.6892,15.1916,0.087 },
{ 2,0,-0.0631,13.3363,0.09272 },
{ 2,1,0.3448,14.5679,0.09556 },
{ 2,2,0.1749,15.7679,0.09371 },
{ 2,3,0.0643,16.3574,0.09254 },
{ 2,4,-0.0191,16.6703,0.09166 },
{ 2,5,-0.0864,16.8386,0.09096 },
{ 2,6,-0.1429,16.9083,0.09036 },
{ 2,7,-0.1916,16.902,0.08984 },
{ 2,8,-0.2344,16.8404,0.08939 },
{ 2,9,-0.2725,16.7406,0.08898 },
{ 2,10,-0.3068,16.6184,0.08861 },
{ 2,11,-0.3381,16.4875,0.08828 },
{ 2,12,-0.3667,16.3568,0.08797 },
{ 2,13,-0.3932,16.2311,0.08768 },
{ 2,14,-0.4177,16.1128,0.08741 },
{ 2,15,-0.4407,16.0028,0.08716 },
{ 2,16,-0.4623,15.9017,0.08693 },
{ 2,17,-0.4825,15.8096,0.08671 },
{ 2,18,-0.5017,15.7263,0.0865 },
{ 2,19,-0.5199,15.6517,0.0863 },
{ 2,20,-0.5372,15.5855,0.08612 },
{ 2,21,-0.5537,15.5278,0.08594 },
{ 2,22,-0.5695,15.4787,0.08577 },
{ 2,23,-0.5846,15.438,0.0856 },
{ 2,24,-0.5989,15.4052,0.08545 },
{ 2,24,-0.5684,15.6881,0.08454 },
{ 2,25,-0.5684,15.659,0.08452 },
{ 2,26,-0.5684,15.6308,0.08449 },
{ 2,27,-0.5684,15.6037,0.08446 },
{ 2,28,-0.5684,15.5777,0.08444 },
{ 2,29,-0.5684,15.5523,0.08443 },
{ 2,30,-0.5684,15.5276,0.08444 },
{ 2,31,-0.5684,15.5034,0.08448 },
{ 2,32,-0.5684,15.4798,0.08455 },
{ 2,33,-0.5684,15.4572,0.08467 },
{ 2,34,-0.5684,15.4356,0.08484 },
{ 2,35,-0.5684,15.4155,0.08506 },
{ 2,36,-0.5684,15.3968,0.08535 },
{ 2,37,-0.5684,15.3796,0.08569 },
{ 2,38,-0.5684,15.3638,0.08609 },
{ 2,39,-0.5684,15.3493,0.08654 },
{ 2,40,-0.5684,15.3358,0.08704 },
{ 2,41,-0.5684,15.3233,0.08757 },
{ 2,42,-0.5684,15.3116,0.08813 },
{ 2,43,-0.5684,15.3007,0.08872 },
{ 2,44,-0.5684,15.2905,0.08931 },
{ 2,45,-0.5684,15.2814,0.08991 },
{ 2,46,-0.5684,15.2732,0.09051 },
{ 2,47,-0.5684,15.2661,0.0911 },
{ 2,48,-0.5684,15.2602,0.09168 },
{ 2,49,-0.5684,15.2556,0.09227 },
{ 2,50,-0.5684,15.2523,0.09286 },
{ 2,51,-0.5684,15.2503,0.09345 },
{ 2,52,-0.5684,15.2496,0.09403 },
{ 2,53,-0.5684,15.2502,0.0946 },
{ 2,54,-0.5684,15.2519,0.09515 },
{ 2,55,-0.5684,15.2544,0.09568 },
{ 2,56,-0.5684,15.2575,0.09618 },
{ 2,57,-0.5684,15.2612,0.09665 },
{ 2,58,-0.5684,15.2653,0.09709 },
{ 2,59,-0.5684,15.2698,0.0975 },
{ 2,60,-0.5684,15.2747,0.09789 }
                                              };
        private static readonly double[,] WHO2006Head = { 
                                               { 1,0,1,34.4618,0.03686 },
{ 1,1,1,37.2759,0.03133 },
{ 1,2,1,39.1285,0.02997 },
{ 1,3,1,40.5135,0.02918 },
{ 1,4,1,41.6317,0.02868 },
{ 1,5,1,42.5576,0.02837 },
{ 1,6,1,43.3306,0.02817 },
{ 1,7,1,43.9803,0.02804 },
{ 1,8,1,44.53,0.02796 },
{ 1,9,1,44.9998,0.02792 },
{ 1,10,1,45.4051,0.0279 },
{ 1,11,1,45.7573,0.02789 },
{ 1,12,1,46.0661,0.02789 },
{ 1,13,1,46.3395,0.02789 },
{ 1,14,1,46.5844,0.02791 },
{ 1,15,1,46.806,0.02792 },
{ 1,16,1,47.0088,0.02795 },
{ 1,17,1,47.1962,0.02797 },
{ 1,18,1,47.3711,0.028 },
{ 1,19,1,47.5357,0.02803 },
{ 1,20,1,47.6919,0.02806 },
{ 1,21,1,47.8408,0.0281 },
{ 1,22,1,47.9833,0.02813 },
{ 1,23,1,48.1201,0.02817 },
{ 1,24,1,48.2515,0.02821 },
{ 1,25,1,48.3777,0.02825 },
{ 1,26,1,48.4989,0.0283 },
{ 1,27,1,48.6151,0.02834 },
{ 1,28,1,48.7264,0.02838 },
{ 1,29,1,48.8331,0.02842 },
{ 1,30,1,48.9351,0.02847 },
{ 1,31,1,49.0327,0.02851 },
{ 1,32,1,49.126,0.02855 },
{ 1,33,1,49.2153,0.02859 },
{ 1,34,1,49.3007,0.02863 },
{ 1,35,1,49.3826,0.02867 },
{ 1,36,1,49.4612,0.02871 },
{ 1,37,1,49.5367,0.02875 },
{ 1,38,1,49.6093,0.02878 },
{ 1,39,1,49.6791,0.02882 },
{ 1,40,1,49.7465,0.02886 },
{ 1,41,1,49.8116,0.02889 },
{ 1,42,1,49.8745,0.02893 },
{ 1,43,1,49.9354,0.02896 },
{ 1,44,1,49.9942,0.02899 },
{ 1,45,1,50.0512,0.02903 },
{ 1,46,1,50.1064,0.02906 },
{ 1,47,1,50.1598,0.02909 },
{ 1,48,1,50.2115,0.02912 },
{ 1,49,1,50.2617,0.02915 },
{ 1,50,1,50.3105,0.02918 },
{ 1,51,1,50.3578,0.02921 },
{ 1,52,1,50.4039,0.02924 },
{ 1,53,1,50.4488,0.02927 },
{ 1,54,1,50.4926,0.02929 },
{ 1,55,1,50.5354,0.02932 },
{ 1,56,1,50.5772,0.02935 },
{ 1,57,1,50.6183,0.02938 },
{ 1,58,1,50.6587,0.0294 },
{ 1,59,1,50.6984,0.02943 },
{ 1,60,1,50.7375,0.02946 },
{ 2,0,1,33.8787,0.03496 },
{ 2,1,1,36.5463,0.0321 },
{ 2,2,1,38.2521,0.03168 },
{ 2,3,1,39.5328,0.0314 },
{ 2,4,1,40.5817,0.03119 },
{ 2,5,1,41.459,0.03102 },
{ 2,6,1,42.1995,0.03087 },
{ 2,7,1,42.829,0.03075 },
{ 2,8,1,43.3671,0.03063 },
{ 2,9,1,43.83,0.03053 },
{ 2,10,1,44.2319,0.03044 },
{ 2,11,1,44.5844,0.03035 },
{ 2,12,1,44.8965,0.03027 },
{ 2,13,1,45.1752,0.03019 },
{ 2,14,1,45.4265,0.03012 },
{ 2,15,1,45.6551,0.03006 },
{ 2,16,1,45.865,0.02999 },
{ 2,17,1,46.0598,0.02993 },
{ 2,18,1,46.2424,0.02987 },
{ 2,19,1,46.4152,0.02982 },
{ 2,20,1,46.5801,0.02977 },
{ 2,21,1,46.7384,0.02972 },
{ 2,22,1,46.8913,0.02967 },
{ 2,23,1,47.0391,0.02962 },
{ 2,24,1,47.1822,0.02957 },
{ 2,25,1,47.3204,0.02953 },
{ 2,26,1,47.4536,0.02949 },
{ 2,27,1,47.5817,0.02945 },
{ 2,28,1,47.7045,0.02941 },
{ 2,29,1,47.8219,0.02937 },
{ 2,30,1,47.934,0.02933 },
{ 2,31,1,48.041,0.02929 },
{ 2,32,1,48.1432,0.02926 },
{ 2,33,1,48.2408,0.02922 },
{ 2,34,1,48.3343,0.02919 },
{ 2,35,1,48.4239,0.02915 },
{ 2,36,1,48.5099,0.02912 },
{ 2,37,1,48.5926,0.02909 },
{ 2,38,1,48.6722,0.02906 },
{ 2,39,1,48.7489,0.02903 },
{ 2,40,1,48.8228,0.029 },
{ 2,41,1,48.8941,0.02897 },
{ 2,42,1,48.9629,0.02894 },
{ 2,43,1,49.0294,0.02891 },
{ 2,44,1,49.0937,0.02888 },
{ 2,45,1,49.156,0.02886 },
{ 2,46,1,49.2164,0.02883 },
{ 2,47,1,49.2751,0.0288 },
{ 2,48,1,49.3321,0.02878 },
{ 2,49,1,49.3877,0.02875 },
{ 2,50,1,49.4419,0.02873 },
{ 2,51,1,49.4947,0.0287 },
{ 2,52,1,49.5464,0.02868 },
{ 2,53,1,49.5969,0.02865 },
{ 2,54,1,49.6464,0.02863 },
{ 2,55,1,49.6947,0.02861 },
{ 2,56,1,49.7421,0.02859 },
{ 2,57,1,49.7885,0.02856 },
{ 2,58,1,49.8341,0.02854 },
{ 2,59,1,49.8789,0.02852 },
{ 2,60,1,49.9229,0.0285 }
                                               };
        private static readonly double[,] WHO2006SSF = { 
                                              { 1,3,-0.3033,7.6899,0.1702 },
{ 1,4,-0.3278,7.4968,0.17097 },
{ 1,5,-0.3503,7.3207,0.17167 },
{ 1,6,-0.3712,7.1588,0.17232 },
{ 1,7,-0.3909,7.0104,0.17293 },
{ 1,8,-0.4097,6.8753,0.17352 },
{ 1,9,-0.4276,6.753,0.17408 },
{ 1,10,-0.4449,6.6428,0.17462 },
{ 1,11,-0.4616,6.5442,0.17514 },
{ 1,12,-0.4777,6.4562,0.17564 },
{ 1,13,-0.4934,6.378,0.17613 },
{ 1,14,-0.5087,6.3085,0.1766 },
{ 1,15,-0.5236,6.2468,0.17707 },
{ 1,16,-0.5381,6.1921,0.17752 },
{ 1,17,-0.5524,6.1435,0.17797 },
{ 1,18,-0.5663,6.1003,0.1784 },
{ 1,19,-0.58,6.0617,0.17883 },
{ 1,20,-0.5934,6.0274,0.17925 },
{ 1,21,-0.6066,5.9972,0.17966 },
{ 1,22,-0.6196,5.9706,0.18006 },
{ 1,23,-0.6324,5.947,0.18046 },
{ 1,24,-0.6449,5.9258,0.18085 },
{ 1,25,-0.6573,5.9067,0.18124 },
{ 1,26,-0.6695,5.8891,0.18162 },
{ 1,27,-0.6816,5.8729,0.18199 },
{ 1,28,-0.6935,5.8576,0.18237 },
{ 1,29,-0.7053,5.8431,0.18273 },
{ 1,30,-0.7169,5.829,0.18309 },
{ 1,31,-0.7283,5.815,0.18345 },
{ 1,32,-0.7397,5.8011,0.18381 },
{ 1,33,-0.7509,5.787,0.18416 },
{ 1,34,-0.762,5.7727,0.1845 },
{ 1,35,-0.773,5.758,0.18485 },
{ 1,36,-0.7839,5.743,0.18519 },
{ 1,37,-0.7947,5.7278,0.18552 },
{ 1,38,-0.8054,5.7125,0.18585 },
{ 1,39,-0.8159,5.6971,0.18618 },
{ 1,40,-0.8264,5.6815,0.18651 },
{ 1,41,-0.8368,5.6658,0.18684 },
{ 1,42,-0.8471,5.65,0.18716 },
{ 1,43,-0.8574,5.6339,0.18748 },
{ 1,44,-0.8675,5.6174,0.18779 },
{ 1,45,-0.8775,5.6006,0.18811 },
{ 1,46,-0.8875,5.5834,0.18842 },
{ 1,47,-0.8974,5.5659,0.18873 },
{ 1,48,-0.9073,5.5482,0.18903 },
{ 1,49,-0.917,5.5303,0.18934 },
{ 1,50,-0.9267,5.5125,0.18964 },
{ 1,51,-0.9363,5.4948,0.18994 },
{ 1,52,-0.9459,5.4774,0.19024 },
{ 1,53,-0.9554,5.4606,0.19053 },
{ 1,54,-0.9648,5.4443,0.19083 },
{ 1,55,-0.9742,5.4288,0.19112 },
{ 1,56,-0.9835,5.414,0.19141 },
{ 1,57,-0.9928,5.4,0.1917 },
{ 1,58,-1.002,5.3868,0.19199 },
{ 1,59,-1.0111,5.3744,0.19227 },
{ 1,60,-1.0202,5.3628,0.19255 },
{ 2,3,-0.2026,7.7846,0.18428 },
{ 2,4,-0.2577,7.5405,0.1843 },
{ 2,5,-0.302,7.3384,0.18428 },
{ 2,6,-0.3394,7.1637,0.18425 },
{ 2,7,-0.3718,7.0118,0.18421 },
{ 2,8,-0.4005,6.8807,0.18412 },
{ 2,9,-0.4263,6.7679,0.18399 },
{ 2,10,-0.4498,6.6707,0.18387 },
{ 2,11,-0.4713,6.5867,0.18381 },
{ 2,12,-0.4912,6.5138,0.18383 },
{ 2,13,-0.5098,6.4505,0.18394 },
{ 2,14,-0.5272,6.3955,0.18415 },
{ 2,15,-0.5435,6.3474,0.18446 },
{ 2,16,-0.559,6.3055,0.18487 },
{ 2,17,-0.5736,6.2689,0.18538 },
{ 2,18,-0.5876,6.2373,0.18598 },
{ 2,19,-0.6009,6.2101,0.18666 },
{ 2,20,-0.6136,6.1868,0.18741 },
{ 2,21,-0.6257,6.1669,0.18823 },
{ 2,22,-0.6374,6.15,0.18911 },
{ 2,23,-0.6487,6.1355,0.19005 },
{ 2,24,-0.6595,6.1232,0.19104 },
{ 2,25,-0.67,6.1129,0.19207 },
{ 2,26,-0.6801,6.1041,0.19315 },
{ 2,27,-0.6899,6.0968,0.19426 },
{ 2,28,-0.6994,6.0905,0.1954 },
{ 2,29,-0.7086,6.0851,0.19657 },
{ 2,30,-0.7175,6.0806,0.19776 },
{ 2,31,-0.7262,6.0766,0.19898 },
{ 2,32,-0.7347,6.0733,0.20021 },
{ 2,33,-0.7429,6.0705,0.20145 },
{ 2,34,-0.7509,6.0683,0.2027 },
{ 2,35,-0.7587,6.0665,0.20395 },
{ 2,36,-0.7664,6.0652,0.20521 },
{ 2,37,-0.7738,6.0643,0.20647 },
{ 2,38,-0.7811,6.0637,0.20773 },
{ 2,39,-0.7882,6.0633,0.20899 },
{ 2,40,-0.7952,6.0632,0.21024 },
{ 2,41,-0.802,6.0632,0.21149 },
{ 2,42,-0.8087,6.0634,0.21273 },
{ 2,43,-0.8152,6.0637,0.21396 },
{ 2,44,-0.8217,6.0641,0.21518 },
{ 2,45,-0.828,6.0647,0.21638 },
{ 2,46,-0.8341,6.0653,0.21758 },
{ 2,47,-0.8402,6.0661,0.21876 },
{ 2,48,-0.8462,6.0669,0.21993 },
{ 2,49,-0.852,6.0679,0.22109 },
{ 2,50,-0.8578,6.069,0.22223 },
{ 2,51,-0.8634,6.0703,0.22335 },
{ 2,52,-0.869,6.0717,0.22447 },
{ 2,53,-0.8745,6.0732,0.22556 },
{ 2,54,-0.8799,6.0748,0.22664 },
{ 2,55,-0.8852,6.0765,0.22771 },
{ 2,56,-0.8904,6.0784,0.22876 },
{ 2,57,-0.8955,6.0803,0.22979 },
{ 2,58,-0.9006,6.0823,0.23081 },
{ 2,59,-0.9056,6.0844,0.23182 },
{ 2,60,-0.9105,6.0865,0.2328 }
                                              };
        private static readonly double[,] WHO2006TSF = { 
                                              { 1,3,0.0027,9.7639,0.16618 },
{ 1,4,-0.0165,9.584,0.17264 },
{ 1,5,-0.0326,9.3885,0.17824 },
{ 1,6,-0.0466,9.1729,0.18304 },
{ 1,7,-0.059,8.9535,0.18685 },
{ 1,8,-0.0703,8.7435,0.18968 },
{ 1,9,-0.0806,8.5518,0.19166 },
{ 1,10,-0.0901,8.3812,0.193 },
{ 1,11,-0.099,8.2323,0.19389 },
{ 1,12,-0.1073,8.1041,0.19453 },
{ 1,13,-0.1152,7.9958,0.19506 },
{ 1,14,-0.1227,7.9064,0.19558 },
{ 1,15,-0.1297,7.8345,0.19612 },
{ 1,16,-0.1365,7.7781,0.19668 },
{ 1,17,-0.143,7.7351,0.19728 },
{ 1,18,-0.1492,7.7036,0.19793 },
{ 1,19,-0.1552,7.6821,0.19862 },
{ 1,20,-0.1609,7.6697,0.19937 },
{ 1,21,-0.1665,7.6652,0.20018 },
{ 1,22,-0.1719,7.6675,0.20105 },
{ 1,23,-0.1771,7.675,0.20196 },
{ 1,24,-0.1821,7.6863,0.20293 },
{ 1,25,-0.187,7.7003,0.20394 },
{ 1,26,-0.1918,7.7156,0.20497 },
{ 1,27,-0.1965,7.7312,0.20603 },
{ 1,28,-0.201,7.7463,0.2071 },
{ 1,29,-0.2054,7.7602,0.20818 },
{ 1,30,-0.2097,7.7726,0.20928 },
{ 1,31,-0.2139,7.7832,0.21039 },
{ 1,32,-0.218,7.792,0.21153 },
{ 1,33,-0.2221,7.7989,0.21269 },
{ 1,34,-0.226,7.804,0.21389 },
{ 1,35,-0.2299,7.8074,0.21513 },
{ 1,36,-0.2336,7.8094,0.21641 },
{ 1,37,-0.2374,7.8101,0.21773 },
{ 1,38,-0.241,7.8096,0.21909 },
{ 1,39,-0.2446,7.808,0.22049 },
{ 1,40,-0.2481,7.8051,0.22194 },
{ 1,41,-0.2515,7.8009,0.22343 },
{ 1,42,-0.2549,7.7954,0.22496 },
{ 1,43,-0.2583,7.7885,0.22653 },
{ 1,44,-0.2616,7.7804,0.22813 },
{ 1,45,-0.2648,7.771,0.22975 },
{ 1,46,-0.268,7.7605,0.2314 },
{ 1,47,-0.2711,7.7489,0.23306 },
{ 1,48,-0.2742,7.7364,0.23473 },
{ 1,49,-0.2772,7.7233,0.23642 },
{ 1,50,-0.2802,7.7096,0.23811 },
{ 1,51,-0.2832,7.6955,0.23981 },
{ 1,52,-0.2861,7.6812,0.24151 },
{ 1,53,-0.289,7.6669,0.24322 },
{ 1,54,-0.2918,7.6525,0.24494 },
{ 1,55,-0.2946,7.6383,0.24666 },
{ 1,56,-0.2974,7.6242,0.24839 },
{ 1,57,-0.3001,7.6104,0.25013 },
{ 1,58,-0.3028,7.5968,0.25186 },
{ 1,59,-0.3055,7.5835,0.2536 },
{ 1,60,-0.3081,7.5706,0.25533 },
{ 2,3,0.1875,9.7516,0.17535 },
{ 2,4,0.1256,9.5866,0.18337 },
{ 2,5,0.0761,9.3716,0.19007 },
{ 2,6,0.0349,9.1194,0.1954 },
{ 2,7,-0.0003,8.8621,0.19934 },
{ 2,8,-0.0307,8.6228,0.20192 },
{ 2,9,-0.0572,8.4164,0.20339 },
{ 2,10,-0.0799,8.2468,0.20413 },
{ 2,11,-0.0995,8.1114,0.20442 },
{ 2,12,-0.1161,8.0042,0.20445 },
{ 2,13,-0.1303,7.9197,0.20432 },
{ 2,14,-0.1424,7.8538,0.20409 },
{ 2,15,-0.1527,7.8041,0.20384 },
{ 2,16,-0.1615,7.7681,0.20363 },
{ 2,17,-0.169,7.7443,0.2035 },
{ 2,18,-0.1755,7.7315,0.2035 },
{ 2,19,-0.1811,7.7287,0.20364 },
{ 2,20,-0.1859,7.7347,0.20393 },
{ 2,21,-0.1901,7.7484,0.20437 },
{ 2,22,-0.1939,7.7692,0.20496 },
{ 2,23,-0.1973,7.7958,0.20568 },
{ 2,24,-0.2004,7.8273,0.20652 },
{ 2,25,-0.2032,7.8628,0.20748 },
{ 2,26,-0.2058,7.9006,0.20855 },
{ 2,27,-0.2081,7.9396,0.20971 },
{ 2,28,-0.2103,7.9786,0.21096 },
{ 2,29,-0.2122,8.0167,0.21228 },
{ 2,30,-0.214,8.0535,0.21366 },
{ 2,31,-0.2155,8.0887,0.21509 },
{ 2,32,-0.217,8.1224,0.21657 },
{ 2,33,-0.2183,8.1545,0.21809 },
{ 2,34,-0.2195,8.1855,0.21964 },
{ 2,35,-0.2207,8.2156,0.22122 },
{ 2,36,-0.2217,8.245,0.22282 },
{ 2,37,-0.2227,8.2738,0.22444 },
{ 2,38,-0.2237,8.3019,0.22608 },
{ 2,39,-0.2246,8.3294,0.22772 },
{ 2,40,-0.2254,8.356,0.22937 },
{ 2,41,-0.2262,8.3818,0.23101 },
{ 2,42,-0.227,8.4068,0.23264 },
{ 2,43,-0.2278,8.4311,0.23427 },
{ 2,44,-0.2285,8.455,0.23587 },
{ 2,45,-0.2292,8.4786,0.23747 },
{ 2,46,-0.2298,8.5019,0.23904 },
{ 2,47,-0.2304,8.525,0.2406 },
{ 2,48,-0.231,8.5481,0.24215 },
{ 2,49,-0.2316,8.5711,0.24367 },
{ 2,50,-0.2321,8.5942,0.24517 },
{ 2,51,-0.2326,8.6174,0.24665 },
{ 2,52,-0.2331,8.6406,0.24811 },
{ 2,53,-0.2336,8.6641,0.24954 },
{ 2,54,-0.2341,8.6876,0.25095 },
{ 2,55,-0.2346,8.7112,0.25233 },
{ 2,56,-0.235,8.7349,0.25369 },
{ 2,57,-0.2355,8.7586,0.25502 },
{ 2,58,-0.2359,8.7824,0.25633 },
{ 2,59,-0.2363,8.8061,0.25761 },
{ 2,60,-0.2368,8.8298,0.25887 }
                                              };

        #endregion WHO 2006 Growth Standards Data


        public static double GetZScore(Indicator indicator, double firstMeasurement, double secondMeasurement, int gender, ref double flag)
        {
            // pre
            Contract.Requires(firstMeasurement >= 0);
            Contract.Requires(secondMeasurement >= 0);
            Contract.Requires(gender >= 1);
            Contract.Requires(gender <= 2);

            var L = -1.0;
            var M = -1.0;
            var S = -1.0;
            var Z = 1.0;
            var ZLMS = new double[4];
            var foundValue = false;

            double[,] reference;

            switch (indicator)
            {
                case Indicator.BMIForAge:
                    reference = WHO2006BMI;
                    break;
                case Indicator.HCForAge:
                    reference = WHO2006Head;
                    break;
                case Indicator.HeightForAge:
                    reference = WHO2006HtAge;
                    break;
                case Indicator.LengthForAge:
                    reference = WHO2006LgthAge;
                    break;
                case Indicator.WeightForAge:
                    reference = WHO2006WtAge;
                    break;
                case Indicator.WeightForHeight:
                    reference = WHO2006WtHt;
                    break;
                case Indicator.WeightForLength:
                    reference = WHO2006WtLgth;
                    break;
                case Indicator.SSFForAge:
                    reference = WHO2006SSF;
                    break;
                case Indicator.TSFForAge:
                    reference = WHO2006TSF;
                    break;
                case Indicator.ACForAge:
                    reference = WHO2006MUAC;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported indicator type for WHO 2006 child growth standards.");
            }

            for (int i = 0; i < reference.Length / 5; i++)
            {
                if (reference[i, 0] == gender && reference[i, 1] == secondMeasurement)
                {
                    L = reference[i, 2];
                    M = reference[i, 3];
                    S = reference[i, 4];
                    foundValue = true;
                    break;
                }
            }

            Z = (firstMeasurement / M);
            Z = Math.Pow(Z, L);
            Z = Z - 1;
            Z = Z / (L * S);

            if (!foundValue)
            {
                ZLMS = InterpZWHO2006(firstMeasurement, secondMeasurement, gender, indicator, ref flag);
                Z = ZLMS[0];
                L = ZLMS[1];
                M = ZLMS[2];
                S = ZLMS[3];
            }
            else
            {
                double stddev = 0;
                if (firstMeasurement < M)
                    stddev = M * (1 - Math.Pow((1 - 2 * L * S), (1 / L))) / 2;
                else
                    stddev = M * (Math.Pow((1 + (2 * L * S)), (1 / L)) - 1) / 2;

                flag = (firstMeasurement - M) / stddev;
            }

            // Re-calculates Z if the LMS z-score is above 3 or below -3, as per http://www.who.int/childgrowth/standards/Chap_7.pdf
            if (Z > 3)
            {
                double SD3pos = 0;
                double SD2pos = 0;
                double SD23pos = 0;

                SD3pos = M * Math.Pow((1 + L * S * 3), 1 / L);
                SD2pos = M * Math.Pow((1 + L * S * 2), 1 / L);
                SD23pos = SD3pos - SD2pos;

                Z = 3 + ((firstMeasurement - SD3pos) / SD23pos);
            }
            else if (Z < -3)
            {
                double SD3neg = 0;
                double SD2neg = 0;
                double SD23neg = 0;

                SD3neg = M * Math.Pow((1 + L * S * (-3)), 1 / L);
                SD2neg = M * Math.Pow((1 + L * S * (-2)), 1 / L);
                SD23neg = SD2neg - SD3neg;

                Z = (-3) + ((firstMeasurement - SD3neg) / SD23neg);
            }

            return Z;
        } // end GetZ_WHO2006()

        private static double[] InterpZWHO2006(double rawScore, double ageMonths, int gender, Indicator indicator, ref double flag)
        {
            double L = -1;
            double M = -1;
            double S = -1;
            double L_u = -1;
            double M_u = -1;
            double S_u = -1;
            double L_l = -1;
            double M_l = -1;
            double S_l = -1;
            double Z = 1;
            double upper = 0;
            double lower = 0;
            double difference = 0;
            double wholeMonths = Math.Truncate(ageMonths);
            difference = ageMonths - wholeMonths;

            double[,] reference;

            switch (indicator)
            {
                case Indicator.BMIForAge:
                    reference = WHO2006BMI;
                    break;
                case Indicator.HCForAge:
                    reference = WHO2006Head;
                    break;
                case Indicator.HeightForAge:
                    reference = WHO2006HtAge;
                    break;
                case Indicator.LengthForAge:
                    reference = WHO2006LgthAge;
                    break;
                case Indicator.WeightForAge:
                    reference = WHO2006WtAge;
                    break;
                case Indicator.WeightForHeight:
                    reference = WHO2006WtHt;
                    break;
                case Indicator.WeightForLength:
                    reference = WHO2006WtLgth;
                    break;
                case Indicator.SSFForAge:
                    reference = WHO2006SSF;
                    break;
                case Indicator.TSFForAge:
                    reference = WHO2006TSF;
                    break;
                case Indicator.ACForAge:
                    reference = WHO2006MUAC;
                    break;
                default:
                    throw new InvalidOperationException();
            }

            if (indicator != Indicator.WeightForHeight && indicator != Indicator.WeightForLength)
            {
                lower = wholeMonths;
                upper = lower + 1.0;
            }
            else
            {
                if (difference > 0.5)
                {
                    lower = wholeMonths + 0.5;
                }
                else
                {
                    lower = wholeMonths;
                }
                upper = lower + 0.5;
            }

            for (int i = 0; i < reference.Length / 5; i++)
            {
                if (reference[i, 0] == gender && reference[i, 1] == lower)
                {
                    L_l = reference[i, 2];
                    M_l = reference[i, 3];
                    S_l = reference[i, 4];
                    break;
                }
            }

            for (int i = 0; i < reference.Length / 5; i++)
            {
                if (reference[i, 0] == gender && reference[i, 1] == upper)
                {
                    L_u = reference[i, 2];
                    M_u = reference[i, 3];
                    S_u = reference[i, 4];
                    break;
                }
            }
            double percent = (ageMonths - lower);
            double percent_u = (upper - ageMonths);

            if (indicator == Indicator.WeightForHeight || indicator == Indicator.WeightForLength)
            {
                percent = percent * 2;
                percent_u = percent_u * 2;
            }

            L = (L_u * percent) + (L_l * percent_u);
            M = (M_u * percent) + (M_l * percent_u);
            S = (S_u * percent) + (S_l * percent_u);

            // Now that we're done, we simply do the stat math to get the Z-score just like we did in GetZScore().
            Z = (rawScore / M);
            Z = Math.Pow(Z, L);
            Z = Z - 1;
            Z = Z / (L * S);

            // Do the flag calculations            
            double stddev = 0;
            if (rawScore < M)
            {
                stddev = M * (1 - Math.Pow((1 - 2 * L * S), (1 / L))) / 2;
            }
            else
            {
                stddev = M * (Math.Pow((1 + (2 * L * S)), (1 / L)) - 1) / 2;
            }

            flag = (rawScore - M) / stddev;

            // Return the z-score to the calling function.
            double[] ZLMS = { Z, L, M, S };
            return ZLMS;

        } // end InterpZWHO2006

    }
}
